﻿#set platform related cmake definition and config
message("Load Platform Linux CMake")

set(NS_LIBS_ROOT ${DIR_LIB}/${TARGET_ABI})
set(PROJECT_LIBS_ROOT ${DIR_PROJECT_LIB}/${TARGET_ABI})

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH ./libs/${TARGET_ABI})

if( EXISTS "${PROJECT_SOURCE_DIR}/CMake/IDE/PlatformLinuxIDE.cmake" )
    include(${PROJECT_SOURCE_DIR}/CMake/IDE/PlatformLinuxIDE.cmake)
endif()

if( EXISTS "${PROJECT_SOURCE_DIR}/CMake/PlatformLinuxCustom.cmake" )
    include(${PROJECT_SOURCE_DIR}/CMake/PlatformLinuxCustom.cmake)
endif()

set(PLATFORM_SOURCE_MAIN ${DIR_SRC}/Platform/linux/NSMainLinux.cpp)

set(PLATFORM_SOURCE 
        #Platform/Linux
        ${PROJECT_PLATFORM_SOURCE}
        ${PROJECT_PLATFORM_CUSTOM_SOURCE}
)

if( ${DEBUG_PROJECT_INTERNAL} )
    set(ENGINE_LIB_NAME NSEngine)
else()
    add_library(libNSEngine SHARED IMPORTED)
    set_target_properties(libNSEngine PROPERTIES IMPORTED_LOCATION ${NS_LIBS_ROOT}/libNSEngine.so)
    set(ENGINE_LIB_NAME libNSEngine)
endif()
        
list(APPEND PLATFORM_LINK_LIBS
    ${ENGINE_LIB_NAME}
)

if( EXISTS "${PROJECT_SOURCE_DIR}/CMake/IDE/PlatformLinuxDepIDE.cmake" )
	include(${PROJECT_SOURCE_DIR}/CMake/IDE/PlatformLinuxDepIDE.cmake)
endif()

message(">>>>>>>>> Platform Linux link libs: " ${PLATFORM_LINK_LIBS})
message(">>>>>>>>> Engine Linux link libs: " ${ENGINE_LINK_LIBS})

set(PLATFORM_CXX_FLAGS "${PROJECT_PLATFORM_CXX_FLAGS} ${PROJECT_PLATFORM_CUSTOM_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-switch -Wno-undefined-var-template -std=c++17 -pthread -fvisibility=hidden")

set(PLATFORM_LINK_FLAGS "${PROJECT_PLATFORM_LINK_FLAGS} ${PROJECT_PLATFORM_CUSTOM_LINK_FLAGS}")

message(">>>>>>>>> Platform Linux CXX flags: " ${PLATFORM_CXX_FLAGS})
message(">>>>>>>>> Platform Linux LINK flags: " ${PLATFORM_LINK_FLAGS})
